Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

friendly-cron

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

friendly-cron

Convert friendly strings to cron patterns

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

friendly-cron

Installation

npm install friendly-cron

Usage

const friendlyCron = require('friendly-cron')

const pattern = friendlyCron('every 15 minutes')
// returns 0 */15 * * * *

API

friendly-cron exposes a single function that returns either a cron expression string or null if the input string isn't parseable.

It's a very simple matching function that looks for "second", "minute", "hour", "day", "month", or "year", optionally proceeded by a number.

Example valid strings:

  • "every hour"
  • "every 15 minutes"
  • "10 days"

Random offsets

It's often the case that you want jobs to run at some interval, but you don't want everything running in batches at, say, the top of the hour.

To add a random offset to your cron pattern, you can add the { random: true } option, like so:

const pattern = friendlyCron('every 15 minutes', { random: true })
// returns something like 34 0-59/15 * * * *

Keywords

FAQs

Package last updated on 15 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc